Skip to main content

Overview

AugmentationCfg defines data augmentation parameters for training image transforms. It controls random augmentations like resized cropping, color jitter, and random erasing.

Class Definition

Fields

Tuple[float, float]
default:"(0.9, 1.0)"
Range of size of the random crop relative to the original image size. Used in RandomResizedCrop.
  • First value: minimum crop scale (e.g., 0.08 = crop can be 8% of original)
  • Second value: maximum crop scale (e.g., 1.0 = crop can be 100% of original)
Common values:
  • (0.08, 1.0): Standard ImageNet training
  • (0.9, 1.0): Light augmentation
Tuple[float, float]
default:"None"
Range of aspect ratio of the random crop. Used in RandomResizedCrop.
  • First value: minimum aspect ratio (e.g., 0.75 = 3:4)
  • Second value: maximum aspect ratio (e.g., 1.33 = 4:3)
If None, defaults to (3/4, 4/3) in torchvision.
Union[float, Tuple[float, ...]]
default:"None"
Color jitter augmentation strength. Can be specified as:
  • float: Applied to brightness, contrast, saturation (e.g., 0.4)
  • Tuple[float, float, float]: (brightness, contrast, saturation)
  • Tuple[float, float, float, float]: (brightness, contrast, saturation, hue)
Values are typically in range [0, 1]. Higher values = stronger augmentation.Example: (0.4, 0.4, 0.4, 0.1) = moderate jitter with slight hue variation
float
default:"None"
Random erasing probability. Probability of applying random erasing augmentation.
  • 0.0: No random erasing
  • 0.25: 25% chance of erasing per image
  • 1.0: Always apply random erasing
Requires use_timm=True.
int
default:"None"
Number of random erasing operations per image when random erasing is applied.Requires use_timm=True.
bool
default:"False"
Whether to use timm (PyTorch Image Models) augmentation transforms.When True, enables advanced augmentations from timm:
  • RandAugment
  • Random erasing
  • More sophisticated augmentation pipelines
When False, uses simple torchvision-based augmentations.
float
default:"None"
Probability of applying color jitter when use_timm=False.
  • 0.0: Never apply color jitter
  • 0.8: Apply color jitter 80% of the time (common default)
  • 1.0: Always apply color jitter
Only used when use_timm=False.
float
default:"None"
Probability of converting image to grayscale (with 3 channels) when use_timm=False.
  • 0.0: Never grayscale
  • 0.2: 20% chance of grayscale (common default)
  • 1.0: Always grayscale
Only used when use_timm=False.

Examples

Standard ImageNet augmentation

Light augmentation

Strong augmentation with timm

No augmentation

Custom aspect ratio range

Grayscale augmentation

Usage with image_transform_v2

Augmentation Strategy Guide

Light Augmentation

  • scale: (0.9, 1.0)
  • color_jitter: 0.2
  • Best for: Fine-tuning, small datasets

Standard Augmentation

  • scale: (0.08, 1.0)
  • color_jitter: 0.4
  • Best for: Training from scratch

Strong Augmentation

  • use_timm: True
  • re_prob: 0.25
  • Best for: Large-scale training

Minimal Augmentation

  • scale: (0.95, 1.0)
  • No color jitter
  • Best for: High-quality datasets

Notes

  • Only used when is_train=True in image_transform_v2()
  • color_jitter_prob and gray_scale_prob are ignored when use_timm=True
  • Random erasing (re_prob, re_count) requires use_timm=True
  • Default values provide minimal augmentation; increase for stronger regularization
  • For contrastive learning, stronger augmentation typically improves performance

See Also